home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / winterp-1.13 / src-server / wc_DrawnB.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-04  |  7.6 KB  |  190 lines

  1. /* -*-C-*-
  2. ********************************************************************************
  3. *
  4. * File:         wc_DrawnB.c
  5. * RCS:          $Header: wc_DrawnB.c,v 1.3 91/03/14 03:14:36 mayer Exp $
  6. * Description:  XM_DRAWN_BUTTON_WIDGET_CLASS
  7. * Author:       Niels Mayer, HPLabs
  8. * Created:      Fri Oct 27 22:26:42 1989
  9. * Modified:     Thu Oct  3 23:56:25 1991 (Niels Mayer) mayer@hplnpm
  10. * Language:     C
  11. * Package:      N/A
  12. * Status:       X11r5 contrib tape release
  13. *
  14. * WINTERP Copyright 1989, 1990, 1991 Hewlett-Packard Company (by Niels Mayer).
  15. * XLISP version 2.1, Copyright (c) 1989, by David Betz.
  16. *
  17. * Permission to use, copy, modify, distribute, and sell this software and its
  18. * documentation for any purpose is hereby granted without fee, provided that
  19. * the above copyright notice appear in all copies and that both that
  20. * copyright notice and this permission notice appear in supporting
  21. * documentation, and that the name of Hewlett-Packard and David Betz not be
  22. * used in advertising or publicity pertaining to distribution of the software
  23. * without specific, written prior permission.  Hewlett-Packard and David Betz
  24. * make no representations about the suitability of this software for any
  25. * purpose. It is provided "as is" without express or implied warranty.
  26. *
  27. * HEWLETT-PACKARD AND DAVID BETZ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  28. * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  29. * IN NO EVENT SHALL HEWLETT-PACKARD NOR DAVID BETZ BE LIABLE FOR ANY SPECIAL,
  30. * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  31. * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  32. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  33. * PERFORMANCE OF THIS SOFTWARE.
  34. *
  35. * See ./winterp/COPYRIGHT for information on contacting the authors.
  36. * Please send modifications, improvements and bugfixes to mayer@hplabs.hp.com
  37. * Post XLISP-specific questions/information to the newsgroup comp.lang.lisp.x
  38. *
  39. ********************************************************************************
  40. */
  41. static char rcs_identity[] = "@(#)$Header: wc_DrawnB.c,v 1.3 91/03/14 03:14:36 mayer Exp $";
  42.  
  43. #include <stdio.h>
  44. #include <Xm/Xm.h>
  45. #include <Xm/DrawnB.h>
  46. #include "winterp.h"
  47. #include "user_prefs.h"
  48. #include "xlisp/xlisp.h"
  49. #include "w_funtab.h"
  50.  
  51.  
  52. /******************************************************************************
  53.  * typedef struct
  54.  * {
  55.  *     int     reason;
  56.  *     XEvent  *event;
  57.  *     Window  window;
  58.  *     int     click_count; -- THIS FIELD EXISTS ONLY IN MOTIF 1.1
  59.  * } XmDrawnButtonCallbackStruct;
  60.  ******************************************************************************/
  61. static void Lexical_Bindings_For_XmDrawnButtonCallbackStruct(bindings_list, lexical_env, cd, o_widget)
  62.      LVAL bindings_list;    /* a list of symbols to which values from XmDrawnButtonCallbackStruct are bound */
  63.      LVAL lexical_env;        
  64.      XmDrawnButtonCallbackStruct* cd;
  65.      LVAL o_widget;        /* XLTYPE_WIDGETOBJ */
  66. {
  67.   extern LVAL s_CALLBACK_WIDGET, s_CALLBACK_REASON, s_CALLBACK_XEVENT, 
  68. #ifdef WINTERP_MOTIF_11
  69.   s_CALLBACK_CLICK_COUNT,
  70. #endif                /* WINTERP_MOTIF_11 */
  71.   s_CALLBACK_WINDOW; /* w_callbacks.c */
  72.   extern LVAL Wcb_Get_Callback_Reason_Symbol();    /* w_callbacks.c */
  73.   register LVAL s_bindname;
  74.  
  75.   for ( ; consp(bindings_list); bindings_list = cdr(bindings_list)) {
  76.  
  77.     s_bindname = car(bindings_list);
  78.  
  79.     if (s_bindname == s_CALLBACK_WIDGET) {
  80.       xlpbind(s_bindname, o_widget, lexical_env);
  81.     }
  82.     else if (s_bindname == s_CALLBACK_REASON) {
  83.       xlpbind(s_bindname, Wcb_Get_Callback_Reason_Symbol(cd->reason), lexical_env);
  84.     }
  85.     else if (s_bindname == s_CALLBACK_XEVENT) {
  86.       xlpbind(s_bindname, (cd->event) ? cv_xevent(cd->event) : NIL, lexical_env);
  87.     }
  88.     else if (s_bindname == s_CALLBACK_WINDOW) {
  89.       xlpbind(s_bindname, (cd->window) ? cv_window(cd->window) : NIL, lexical_env);
  90.     }
  91. #ifdef WINTERP_MOTIF_11
  92.     else if (s_bindname == s_CALLBACK_CLICK_COUNT) {
  93.       xlpbind(s_bindname, cvfixnum((FIXTYPE) (cd->click_count)), lexical_env);
  94.     }
  95. #endif                /* WINTERP_MOTIF_11 */
  96.     else {
  97.       extern char temptext[];    /* from winterp.c */
  98.       sprintf(temptext,
  99. #ifdef WINTERP_MOTIF_11
  100.           "Unknown binding name in XmDrawnButtonCallbackStruct callback evaluator. Valid symbols are [%s %s %s %s %s].",
  101. #else
  102.           "Unknown binding name in XmDrawnButtonCallbackStruct callback evaluator. Valid symbols are [%s %s %s %s].",
  103. #endif                /* WINTERP_MOTIF_11 */
  104.           (char*) getstring(getpname(s_CALLBACK_WIDGET)),
  105.           (char*) getstring(getpname(s_CALLBACK_REASON)),
  106.           (char*) getstring(getpname(s_CALLBACK_XEVENT)),
  107. #ifdef WINTERP_MOTIF_11
  108.           (char*) getstring(getpname(s_CALLBACK_CLICK_COUNT)),
  109. #endif                /* WINTERP_MOTIF_11 */
  110.           (char*) getstring(getpname(s_CALLBACK_WINDOW)));
  111.       xlerror(temptext, s_bindname);
  112.     }
  113.   }
  114. }
  115.  
  116.  
  117. /******************************************************************************
  118.  * This is called indirectly via XtAddCallback() for callbacks returning
  119.  * an XmDrawnButtonCallbackStruct as call_data.
  120.  ******************************************************************************/
  121. static void XmDrawnButtonCallbackStruct_Callbackproc(widget, client_data, call_data)
  122.      Widget    widget;
  123.      XtPointer client_data;
  124.      XtPointer call_data;
  125. {
  126.   extern void Wcb_Meta_Callbackproc();    /* w_callbacks.c */
  127.  
  128.   Wcb_Meta_Callbackproc(client_data, call_data,
  129.             Lexical_Bindings_For_XmDrawnButtonCallbackStruct,
  130.             NULL);
  131. }
  132.  
  133.  
  134. /******************************************************************************
  135.  * Same as WIDGET_CLASS's :add_callback method except that this understands
  136.  * how to get values from the XmDrawnButtonCallbackStruct.
  137.  * Specifying one or more of the following symbols in the callback bindings 
  138.  * list will bind that symbol's value in the lexical environment of the callback:
  139.  * CALLBACK_WIDGET
  140.  * CALLBACK_REASON
  141.  * CALLBACK_XEVENT
  142.  * CALLBACK_WINDOW
  143.  ******************************************************************************/
  144. LVAL Xm_Drawn_Button_Widget_Class_Method_ADD_CALLBACK()
  145. {
  146.   extern LVAL Wcb_Meta_Method_Add_Callback(); /* w_callbacks.c */
  147.  
  148.   return (Wcb_Meta_Method_Add_Callback(XmDrawnButtonCallbackStruct_Callbackproc, FALSE));
  149. }
  150.  
  151.  
  152. /******************************************************************************
  153.  * Same as WIDGET_CLASS's :set_callback method except that this understands
  154.  * how to get values from the XmDrawnButtonCallbackStruct.
  155.  * Specifying one or more of the following symbols in the callback bindings 
  156.  * list will bind that symbol's value in the lexical environment of the callback:
  157.  * CALLBACK_WIDGET
  158.  * CALLBACK_REASON
  159.  * CALLBACK_XEVENT
  160.  * CALLBACK_WINDOW
  161.  ******************************************************************************/
  162. LVAL Xm_Drawn_Button_Widget_Class_Method_SET_CALLBACK()
  163. {
  164.   extern LVAL Wcb_Meta_Method_Add_Callback(); /* w_callbacks.c */
  165.  
  166.   return (Wcb_Meta_Method_Add_Callback(XmDrawnButtonCallbackStruct_Callbackproc, TRUE));
  167. }
  168.  
  169.  
  170. /******************************************************************************
  171.  *
  172.  ******************************************************************************/
  173. Wc_DrawnB_Init()
  174. {
  175.   LVAL o_XM_DRAWN_BUTTON_WIDGET_CLASS;
  176.   extern LVAL Wcls_Create_Subclass_Of_WIDGET_CLASS(); /* w_classes.c */
  177.   extern      xladdmsg();    /* from xlobj.c */
  178.  
  179.   o_XM_DRAWN_BUTTON_WIDGET_CLASS =
  180.     Wcls_Create_Subclass_Of_WIDGET_CLASS("XM_DRAWN_BUTTON_WIDGET_CLASS",
  181.                      xmDrawnButtonWidgetClass);
  182.  
  183.   xladdmsg(o_XM_DRAWN_BUTTON_WIDGET_CLASS, ":ADD_CALLBACK",
  184.            FTAB_Xm_Drawn_Button_Widget_Class_Method_ADD_CALLBACK);
  185.  
  186.   xladdmsg(o_XM_DRAWN_BUTTON_WIDGET_CLASS, ":SET_CALLBACK",
  187.            FTAB_Xm_Drawn_Button_Widget_Class_Method_SET_CALLBACK);
  188. }
  189.